/*-------------------------------------------------------- 
* Module Name : OLView
* Version : 1.0
* 
* Software Name : Qt App Template
* Version : 1.0
*
* Copyright � 2010 � 2011 France T�l�com
* This software is distributed under the LGPL v2.1 license,
* the text of which is available at http://www.gnu.org/licenses/lgpl-2.1.html
* or see the "LICENSE.txt" file for more details.
*
*--------------------------------------------------------
* File Name   : OLView.h
*
* Created     : 07 June 2011
* Author(s)   : Omer Saleem
*
* Description :
* UI container for main view area for the application content.
* This object manages the view stack as well as animations
* for when navigating between views.
*
*--------------------------------------------------------
* 1.0 - First open source release
*
*/

#ifndef OLVIEW_H
#define OLVIEW_H

#include <QWidget>

#include "OLApplication.h"

class QPropertyAnimation;
class OLModalBackground;

class OLView : public QWidget
{
Q_OBJECT
public:
    explicit OLView(QWidget *parent = 0);
    ~OLView();

    QWidget* currentView() const;
    void setView(QWidget* view, OLApplication::OrientationOptions options, bool keep);
    void addStackedView(QWidget* view, OLApplication::OrientationOptions options, bool keep);

public slots:
    void back();

private slots:
    void handleCompleteAnimation();

protected:
    void resizeEvent(QResizeEvent * event);

signals:
    void handleResize(const QSize& size);
    void viewAdded(QWidget* view);
    void baseViewActivated();
    void viewRemoved(QWidget* view);
    void viewFocusIn(QWidget* view);
    void viewFocusOut(QWidget* view);

private:
    //void removeView(QWidget* view);
    void baseViewIn(QWidget* view);
    void stackViewIn(QWidget* view);
    void keepOrDeleteView(QWidget* view, bool afterAnim);
    void killAnimation();
    bool orientationChange(QWidget* newview);

private:
    QList<QWidget*> m_viewStack;
    OLModalBackground* m_fader;
    QPropertyAnimation* m_anim;
    QPropertyAnimation* m_fadeAnim;
    QWidget* m_viewToRemove;
};

#endif // OLVIEW_H
